import functools
class Solution(object):
    def findPaths(self, m, n, maxMove, startRow, startColumn):
        @functools.cache
        def dfs(r, c, move):
            if not 0 <= r < m or not 0 <= c < n:
                return 1
            if move == 0:
                return 0
            return dfs(r - 1, c, move - 1) + dfs(r + 1, c, move - 1) + dfs(r, c - 1, move - 1) + dfs(r, c + 1, move - 1)

        return dfs(startRow, startColumn, maxMove) % (10 ** 9 + 7)

